package cn.rkylin.oms.push.adapter;

import cn.rkylin.apollo.common.util.BeanUtils;
import cn.rkylin.oms.system.shop.domain.Shop;

/**
 * 推送数据工厂
 * 
 * @author jipengcheng
 * @version 1.0
 * @created 2017.02.13
 */
public class PushAdapterFactory {

    /**
     * 构造函数
     */
    private PushAdapterFactory() {

    }

    /**
     * 根据不同的平台获取相关的适配器
     * @param shop 网店实体
     * @return
     * @throws Exception
     */
    public static PushAdapter getPushAdapter(Shop shop) throws Exception {
		if (shop != null && "淘宝".equals(shop.getShopType())) {
			TaobaoPushAdapter taobaoPushAdapter = BeanUtils.getBean("taobaoPushAdapter");
			taobaoPushAdapter.setPushVisitor((TaobaoPushVisitor) BeanUtils.getBean("taobaoPushVisitor"));
			return taobaoPushAdapter;
		} else if (shop != null && "小V铺".equals(shop.getShopType())) {
			XvpPushAdapter xvpPushAdapter = BeanUtils.getBean("xvpPushAdapter");
			xvpPushAdapter.setPushVisitor((XvpPushVisitor) BeanUtils.getBean("xvpPushVisitor"));
			return xvpPushAdapter;
		} else if (shop != null && "唯品会直发".equals(shop.getShopType())) {
			VipPushAdapter vipPushAdapter = BeanUtils.getBean("vipPushAdapter");
			vipPushAdapter.setPushVisitor((VipPushVisitor) BeanUtils.getBean("vipPushVisitor"));
			return vipPushAdapter;
		}
        
        return null;
    }
}
